package com.souku.finance.application.ui.mine;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.souku.finance.application.R;
import com.souku.finance.application.base.BaseTitleBarActivity;
import com.souku.finance.application.utils.Constant;
import com.souku.finance.application.utils.ShareUtil;
import com.souku.finance.application.utils.level.StringUtils;

import java.text.ParseException;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class EAccountActivity extends BaseTitleBarActivity {

    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.et_identity_card)
    EditText etIdentityCard;
    @BindView(R.id.btn_open)
    Button btnOpen;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_eaccount_e);
        ButterKnife.bind(this);
    }

    @Override
    public void internet() {

    }

    @OnClick(R.id.btn_open)
    public void onViewClicked() {
        String realname = etName.getText().toString();
        String idCardNumber = etIdentityCard.getText().toString();

        if (TextUtils.isEmpty(realname)) {
            Toast.makeText(EAccountActivity.this, "姓名不能为空", Toast.LENGTH_LONG).show();
            return;
        }

        if (!StringUtils.IDCardValidate(idCardNumber)) {
            Toast.makeText(EAccountActivity.this, "身份证号码有误", Toast.LENGTH_LONG).show();
            return;
        }

        Intent intent = new Intent(this, EAccountWebActivity.class);
        intent.putExtra("realname", realname);
        intent.putExtra("idCardNumber", idCardNumber);
        startActivityForResult(intent, 200);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 300) {
            if (ShareUtil.getInstance().getString(Constant.IsBind).equals("1")) {
                finish();
            }
        }
    }
}
